package com.sheyu.mall.product.service;

import com.sheyu.mall.product.dao.category.CategoryDao;
import com.sheyu.mall.product.entity.category.CategoryEntity;
import com.sheyu.mall.product.service.category.CategoryService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;
import java.util.List;

/**
 * @author sheyu
 * @Desciption:
 * @date 2020/10/4 11:18 上午
 */

@RunWith(SpringRunner.class)
@SpringBootTest
public class Category {

    @Autowired
    CategoryService categoryService;

    @Autowired
    CategoryDao categoryDao;

    @Test
    public void testCategoryById(){
        CategoryEntity categoryEntities = categoryDao.selectCategoryIdBySQL(1L);
        System.out.println(categoryEntities);
    }

    @Test
    public void testCategoryByList(){
        List<CategoryEntity> categoryEntityList = categoryDao.selectListBySQL();
        System.out.println(categoryEntityList);
    }

    @Test

    public void testUpdateById(){
        CategoryEntity categoryEntity1 = categoryDao.selectById(1453L);
        System.out.println(categoryEntity1);
//        categoryEntity.setCatId(1445L);
//        categoryEntity.setName("java编程艺术");
//        categoryDao.updateById(categoryEntity);
    }

    @Test
    public  void testInsert(){
        CategoryEntity  categoryEntity = new CategoryEntity();
        categoryEntity.setName("计算机");
        categoryEntity.setCatLevel(3);
//        categoryEntity.setDeleted(0);
//        categoryEntity.setParentCid(22L);
        categoryService.save(categoryEntity);
    }

    @Test
    public void testDeleted(){
        List<Long> catIds = new ArrayList<>();
        catIds.add(1L);
        catIds.add(2L);
        categoryService.removeCategoryByIds(catIds);
    }

    @Test
    public void testGetAllCategories(){
        List<CategoryEntity> categoryEntityList = categoryService.getAllCategories();
        System.out.println(categoryEntityList);
    }

    @Test
    public void testemoveCategoryByIds(){
        List<Long> catIds = new ArrayList<>();
        catIds.add(225L);
        catIds.add(1L);
        categoryService.removeCategoryByIds(catIds);
    }

    @Test
    public void testSelectListByParentCidBySQL(){
        List<CategoryEntity> categoryEntities = categoryDao.selectListByParentCidBySQL();
        System.out.println(categoryEntities);
    }

}
